package com.snailhd.common.util;

import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;


public class ScheduledThreadPoolManager {
	
	private static volatile ScheduledThreadPoolManager _instance;
	private ScheduledThreadPoolExecutor pool;
	
	
	private ScheduledThreadPoolManager(){
		pool = new ScheduledThreadPoolExecutor(5);
	}
	
	public static ScheduledThreadPoolManager getInstance(){
		if(null == _instance){
			synchronized (ScheduledThreadPoolManager.class) {
				if(null==_instance){
					_instance = new ScheduledThreadPoolManager();
				}
			}
		}
		return _instance;
	}
	
	/**
	 * @param command 为线程
	 * @param delay 首次执行的延迟时间
	 * @param unit 最后一个参数为时间单位
	 */
	public void schedule(Runnable command, long delay, TimeUnit unit){
		pool.schedule(command, delay,unit);
	}
	
	
}
